require('../../assets/css/index.js')

require('./login.less')

let CaptchaMini = require("captcha-mini")


let dom = require('../../utils/dom')
let http = require('../../utils/http')
let valdator = require('../../utils/valdator')
let local = require('../../utils/local')

dom.ready(function () {
    let account = dom.getEl('#account')
    let pwd = dom.getEl('#pwd')
    let btn = dom.getEl('#btn')

    
    
    btn.addEventListener('click',function(){
        if(account.value&&pwd.value){
            http.post('/api/user/login',{
                account:account.value,
                password:pwd.value
            },function(res){
                
                if(res.errno==0){
                    weui.topTips('登录成功，即将跳转！')
                    local.set('userInfo',res.data)
                    localStorage.setItem('ygc',res.data.token)
                    window.setTimeout(function(){
                        window.location.href='first.html'
                    },2000)
                }else{
                    weui.topTips('登陆失败！！')
                }
            })
        }else{
            weui.topTips('请输入账号密码')
        }
    })
})